package com.attendance.www.hr.service.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.attendance.www.hr.dao.mapper.SystemConfigureMapper;
import com.attendance.www.hr.entitys.SystemConfigure;
import com.attendance.www.hr.entitys.SystemConfigureExample;
import com.attendance.www.hr.service.ISystemConfigureService;

@Service
public class SystemConfigureServiceImpl implements ISystemConfigureService {
	@Resource
	private SystemConfigureMapper systemConfigureDao;

	@Override
	public Date getEffectiveDate() {
		// TODO Auto-generated method stub
		Date effectiveDate = systemConfigureDao.selectByExample(new SystemConfigureExample()).get(0).getEffectiveDate();
		if(effectiveDate==null) {
			effectiveDate= new Date();
		}
		return effectiveDate;
	}

	/**
	 * 获取配置表里，接收邮件的邮箱地址
	 */
	@Override
	public String getEmail() {
		// TODO Auto-generated method stub
		String emailInfo = systemConfigureDao.selectByExample(new SystemConfigureExample()).get(0).getMailReceive();
		return emailInfo;
	}

	/**
	 * 更新接收者邮箱
	 */
	@Override
	public boolean updateEmail(String emailAddress) {
		// TODO Auto-generated method stub
		SystemConfigure sys = systemConfigureDao.selectByExample(new SystemConfigureExample()).get(0);
		sys.setMailReceive(emailAddress);
		int record = systemConfigureDao.updateByPrimaryKeySelective(sys);
		if (record >0) {
			return true;
		}
		return false;
	}



}
